package com.donglan.pethome.pet.controller;

import com.alibaba.fastjson.JSONObject;
import com.donglan.pethome.basic.util.AjaxResult;
import com.donglan.pethome.basic.util.PageList;
import com.donglan.pethome.basic.util.RedisUtil;
import com.donglan.pethome.organization.domain.Employee;
import com.donglan.pethome.organization.domain.Shop;
import com.donglan.pethome.organization.service.ShopService;
import com.donglan.pethome.pet.domain.Pet;
import com.donglan.pethome.pet.domain.SearchMasterMessage;
import com.donglan.pethome.pet.query.PetQuery;
import com.donglan.pethome.pet.query.SearchMasterMessageQuery;
import com.donglan.pethome.pet.service.PetService;
import com.donglan.pethome.pet.service.SearchMasterMsgService;
import com.donglan.pethome.pet.util.TemporaryAsShopLogin;
import com.donglan.pethome.product.domain.Product;
import com.donglan.pethome.product.query.ProductQuery;
import com.donglan.pethome.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * @Author: zhangdonghui
 * @Date: 2022/2/22 16:59
 * 宠物分页展示列表的controller
 */
@RestController
@RequestMapping("/pet")
public class PetController {

    @Autowired
    private PetService petService;

    //===================================以下代码都是门户网站对应的接口=================================================

    @PatchMapping("/loadPets")
    public PageList<Pet> findHomePageByQuery(@RequestBody PetQuery petQuery){
        // 只查询上架状态的服务
        petQuery.setState(1);
        // 分页查询
        return petService.loadPageByQuery(petQuery);
    }

    /**
     * 根据id查询服务对象
     * @param id
     * @return  服务对象和服务明细数据
     */
    @GetMapping("/{id}")
    public Pet findHomeById(@PathVariable("id") Long id){
        return petService.loadById(id);
    }
}
